home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / dev / mui / MUIPlusPlus.lha / Source / MainHeader / HeaderComment < prev    next >
Encoding:
Text File  |  1997-03-12  |  6.2 KB  |  159 lines

  1.  
  2. MUI - MagicUserInterface
  3. (c) 1993-1996 Stefan Stuntz
  4.  
  5. C++ Header File for MUI 3.8 by Nicholas Allen
  6.  
  7. This header allows the use of MUI through C++ classes instead of using
  8. C and BOOPSI. The advantage of this approach is that more errors will
  9. be found at compile time and it makes the code easier to read and write.
  10.  
  11. *************************************************************************
  12. Creating objects
  13. *************************************************************************
  14.  
  15. Objects can be declared in C++ without initializing them by using the
  16. following syntax:
  17.  
  18.     CMUI_<class>  object;
  19.  
  20. For example:
  21.  
  22.     CMUI_Window   myWindow;
  23.  
  24. Because this does no initialization the muimaster.library does not
  25. have to be open at this point. This allows objects to be declared
  26. within structures, classes and as global variables without having to
  27. initialize them first.
  28.  
  29. Having declared an object it could be initialized it later using the
  30. following syntax:
  31.  
  32.     object = CMUI_<class> (<tags>);
  33.  
  34.     eg:
  35.  
  36.     myWindow = CMUI_Window (MUIA_Window_Title, "A test window",
  37.                             .
  38.                             .
  39.                             .
  40.                             TAG_DONE);
  41.  
  42. You can also declare and initialize objects at the same time by using
  43. the following syntax:
  44.  
  45.     CMUI_<class>  object (<tags>);
  46.  
  47. For example:
  48.  
  49.     CMUI_Slider   mySlider (MUIA_Numeric_Min, 1,
  50.                             MUIA_Numeric_Max, 10,
  51.                             TAG_DONE);
  52.  
  53. Versions of muimaster.library after V8 come with the ability to create
  54. common objects using MUI_MakeObject(). This can also be done in C++ by
  55. specifying the MakeObject parameters instead of the tag list for
  56. objects that are supported by MakeObject. For example:
  57.  
  58.     CMUI_Slider     mySlider ("example slider", 0, 100);
  59.     CMUI_Button     myButton ("_Ok");
  60.     CMUI_Checkmark  myCheckmark ("example checkmark");
  61.  
  62. The following classes allow creation of objects in this manner:
  63.  
  64.     Class name              Parameters
  65.     ----------              ----------
  66.  
  67.     CMUI_Label              STRPTR label, ULONG flags
  68.     CMUI_Button             STRPTR label
  69.     CMUI_Checkmark          STRPTR label
  70.     CMUI_Cycle              STRPTR label, STRPTR *entries
  71.     CMUI_Radio              STRPTR label, STRPTR *entries
  72.     CMUI_Slider             STRPTR label, LONG min, LONG max
  73.     CMUI_String             STRPTR label, LONG maxlen
  74.     CMUI_HSpace             LONG space
  75.     CMUI_VSpace             LONG space
  76.     CMUI_HBar               LONG space
  77.     CMUI_VBar               LONG space
  78.     CMUI_Menustrip          struct NewMenu *nm, ULONG flags
  79.     CMUI_Menuitem           STRPTR label, STRPTR shortcut, ULONG flags, ULONG data
  80.     CMUI_BarTitle           STRPTR label
  81.     CMUI_Numericbutton      STRPTR label, LONG min, LONG max, STRPTR format
  82.  
  83. *************************************************************************
  84. Disposing objects
  85. *************************************************************************
  86.  
  87. When you have finished using an object you need to dispose of it.
  88. Normally you will only have to dispose the Application object as this
  89. will automatically dispose all of its children. However, if you add
  90. and remove objects dynamically to the application then they will need
  91. to be disposed when they are removed. To dispose of an object you just
  92. call its Dispose method. For example:
  93.  
  94.     myApplication.Dispose();
  95.  
  96. will dispose of the application object and its children. The same
  97. syntax is used to dispose of any kind of object.
  98.  
  99. If you dispose of an object that is connected to a parent object then
  100. when the parent object is disposed it will get disposed twice and this
  101. will cause your program to crash. If MUIPlusPlus is in debug mode then
  102. an error message will be generated if you try to dispose an object
  103. connected to a parent and the object won't be disposed.
  104.  
  105. *************************************************************************
  106. Getting and setting attributes
  107. *************************************************************************
  108.  
  109. To get an attribute from an object you call the appropriate get member
  110. function. The get member function has the same name as the last part
  111. of the tag name in MUI. Thus to check if a window is open or not (i.e.
  112. get its MUIA_Window_Open attribute) you would write:
  113.  
  114.     if (myWindow.Open())
  115.     {
  116.         .
  117.         .
  118.         .
  119.     }
  120.  
  121.  
  122. To set an attribute you call the appropraite set member function. The
  123. set member function has the same name as the last part of the tag name
  124. in MUI but is peceeded by "Set". The value to set the attribute is
  125. passed as a parameter. Thus to open a window object (i.e. set its
  126. MUIA_Window_Open attribute to TRUE) you would write:
  127.  
  128.     myWindow.SetOpen(TRUE);
  129.  
  130. *************************************************************************
  131. Calling methods
  132. *************************************************************************
  133.  
  134. To call a method just call the member function of the object with the
  135. same name as the last part of the method tag with the parameters to
  136. the method. For example, to call the Jump method for a List object to
  137. jump to line 10 you would write:
  138.  
  139.     myList.Jump(10);    // Scroll the 10th line into view
  140.  
  141. Because of the way BOOPSI has been implemented calling methods that
  142. have a variable number of arguments cannot be called in exactly the
  143. same way as those with a fixed number of arguments. In MUIPlusPlus you
  144. must pass an object called "sva" (meaning Start Variable Args) as the
  145. first argument to the method and then any other arguments must follow.
  146. For example, the Notify method of an object takes a variable number of
  147. arguments. To setup a notification for an application object to return
  148. MUIV_Application_ReturnID_Quit when a window object is closed:
  149.  
  150.     window.Notify(sva, MUIA_Window_CloseRequest, TRUE,
  151.                   app, 2, MUIM_Application_ReturnID,
  152.                   MUIV_Application_ReturnID_Quit);
  153.  
  154. The only difference, therefore, is that you must pass "sva" as the
  155. first parameter. If you forget to do this then the compiler will
  156. object (you will not cause any problems in your program by forgetting
  157. to do this- it just won't compile).
  158.  
  159.